import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.factories.FormFactory;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class createAccntGUI extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;
	private JComboBox comboBox = new JComboBox();

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					createAccntGUI frame = new createAccntGUI();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public createAccntGUI() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 326, 216);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new FormLayout(new ColumnSpec[] {
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("default:grow"),
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("default:grow"),
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,},
			new RowSpec[] {
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,}));
		
		JLabel lblCreateAccount = new JLabel("Create Account");
		contentPane.add(lblCreateAccount, "8, 2, left, default");
		
		JLabel lblUsername = new JLabel("Username:");
		contentPane.add(lblUsername, "6, 6, right, default");
		
		textField = new JTextField();
		contentPane.add(textField, "8, 6, 2, 1, fill, default");
		textField.setColumns(10);
		
		JLabel lblPassword = new JLabel("Password:");
		contentPane.add(lblPassword, "6, 8, right, default");
		
		textField_1 = new JTextField();
		contentPane.add(textField_1, "8, 8, 2, 1, fill, default");
		textField_1.setColumns(10);
		
		JLabel lblTypeOfUser = new JLabel("Type of User:");
		contentPane.add(lblTypeOfUser, "6, 10, right, default");
		
		
		comboBox.setModel(new DefaultComboBoxModel(new String[] {"Students/Faculty", "Employee"}));
		comboBox.setSelectedIndex(0);
		contentPane.add(comboBox, "8, 10, 2, 1, fill, default");
		
		JButton btnDone = new JButton("Done");
		btnDone.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				//tasks task = new tasks();
				//System.out.println(comboBox.getSelectedItem().toString());
				 if (comboBox.getSelectedItem().toString().equalsIgnoreCase("Students/Faculty")){
					 memberGUI mGUI = new memberGUI();
					 mGUI.setUser(textField.getText());
					 mGUI.setPW(textField_1.getText());
					 mGUI.setVisible(true);
					 setVisible(false);
					 
				 }
				 else{
				tasks.createAccount(textField.getText(), textField_1.getText(), comboBox.getSelectedItem().toString());
				setVisible(false);
				 }
				 
				 
				
				
			}
		});
		contentPane.add(btnDone, "8, 12");
	}

}
